package top.maof.book.model;

import com.baomidou.mybatisplus.annotation.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.data.annotation.Id;
import top.maof.book.annotation.FieldType;
import top.maof.book.annotation.Key;
import top.maof.lightsearch.annotation.Property;
import top.maof.lightsearch.annotation.Type;

import java.io.Serializable;
import java.util.Date;

@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
@TableName("book")
//@Document(indexName = "novel")
@Type("book")
public class Book implements Serializable {
    @Key
    @FieldType(weight = 2.0)
    @Id
    @TableId(type = IdType.AUTO)
    @top.maof.lightsearch.annotation.Key("id")
    private Integer id;

    @FieldType(weight = 1.5)
    @Property(value = "name")
   /* @Field(type = org.springframework.data.elasticsearch.annotations.FieldType.Text,
            analyzer = "ik_max_word", store = true)*/
    private String name;

    @FieldType(weight = 1.5)
   /* @Field(type = org.springframework.data.elasticsearch.annotations.FieldType.Text,
            analyzer = "ik_max_word", store = true)*/
    @Property(value = "author")
    private String author;

    @FieldType(isIndexed = false, isTokenized = false)
  /*  @Field(type = org.springframework.data.elasticsearch.annotations.FieldType.Keyword,
            store = true)*/
    @Property(value = "img", isIndexed = false, isTokenized = false)
    private String img;

    @FieldType(isIndexed = true, isTokenized = false, weight = 1.2)
  /*  @Field(type = org.springframework.data.elasticsearch.annotations.FieldType.Keyword,
            store = true)*/
    @Property(value = "classify", isTokenized = false)
    private String classify;

    @FieldType(isIndexed = true, isTokenized = false, weight = 1.2)
   /* @Field(type = org.springframework.data.elasticsearch.annotations.FieldType.Keyword,
            store = true)*/
    @Property(value = "state", isTokenized = false)
    private String state;


    @FieldType(isIndexed = false, isTokenized = false)
   /* @Field(type = org.springframework.data.elasticsearch.annotations.FieldType.Date,
            store = true)*/
    private Date insertDate;

    @FieldType(isIndexed = false, isTokenized = false)

   /* @Field(type = org.springframework.data.elasticsearch.annotations.FieldType.Date,
            store = true)*/
    private Date updateDate;

    @FieldType(isIndexed = true, isTokenized = false)
   /* @Field(type = org.springframework.data.elasticsearch.annotations.FieldType.Keyword,
            store = true)*/

    private String sourceSite;

    @FieldType(isIndexed = false, isTokenized = false)
   /* @Field(type = org.springframework.data.elasticsearch.annotations.FieldType.Keyword,
            store = true)*/

    private String sourceUrl;

    @FieldType(isIndexed = false, isTokenized = false)
  /*  @Field(type = org.springframework.data.elasticsearch.annotations.FieldType.Date,
            store = true)*/

    private Date startDate;

    @FieldType
  /*  @Field(type = org.springframework.data.elasticsearch.annotations.FieldType.Text,
            analyzer = "ik_max_word", store = true)*/
    @Property("synopsis")
    private String synopsis;

    public Book(Integer id, String name, String author, String img, String classify, String state, Date insertDate,
                Date updateDate, String sourceSite, String sourceUrl, Date startDate, String synopsis) {
        this.id = id;
        this.name = name;
        this.author = author;
        this.img = img;
        this.classify = classify;
        this.state = state;
        this.insertDate = insertDate;
        this.updateDate = updateDate;
        this.sourceSite = sourceSite;
        this.sourceUrl = sourceUrl;
        this.startDate = startDate;
        this.synopsis = synopsis;
    }


    @FieldType(isIndexed = false, isTokenized = false, isStored = false)
    @TableField(fill = FieldFill.INSERT)

    private Long insertTime;

    @FieldType(isIndexed = false, isTokenized = false, isStored = false)
    @TableField(fill = FieldFill.INSERT_UPDATE)

    private Long updateTime;
}
